package com.chinasoft.one_to_many;

import com.chinasoft.bean.Card;
import com.chinasoft.bean.Classes;
import com.chinasoft.one_to_one.CardMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Test02 {

    @Test
    public void testSelect() throws IOException {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        ClassesMapper mapper = sqlSession.getMapper(ClassesMapper.class);
        List<Classes> classes = mapper.selectAll();

        classes.forEach(System.out::println);


    }


}